import config from 'config/config'
import * as constants from 'src/AppConstants'
import cache from 'commons/cache'
import {mapState} from 'vuex'

export default {
    components: {
    },
    computed: {
        ...mapState({
            navs: (state) => (state.navs || []).length == 0?JSON.parse(cache.getValue(constants.CACHE_USER_NAV)):state.navs
        }),
        uploadAction() {
            return config.api_base + '/resource'
        }
    },
    methods: {
        getNav() {
            let path = this.$route.path
            let navName = path.split("/")[1]
            let nav = this.navs.filter((nav) => nav.name == navName)[0]
            return nav || this.navs[0]
        }
    }
}
